﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using prjKQXS_DLL;
using prjKQXS_DLL.Ve_so;
using prjKQXS_DLL.Hop_dong;
using prjKQXS_Report.Boc;
using DevExpress.XtraSplashScreen;
using DevExpress.XtraReports.UI;
using DevExpress.XtraGrid;

namespace prjKQXS_UI.Boc
{
    public partial class frmInbocph5 : DevExpress.XtraEditors.XtraForm
    {
        public frmInbocph5()
        {
            InitializeComponent();
        }

        private void btnin_Click(object sender, EventArgs e)
        {
            BienTc.denngay = (DateTime)clsCommon.Parse(deNgay.Text, 4);
            BienTc.KyHieuVe = txtkyhieu.Text.ToString().Trim();
            BienTc.GiaVe = (Int32)clsCommon.Parse(txtgiave.Text, 0);
             if (BienTc.KyHieuVe.Length > 4 || BienTc.KyHieuVe.Length == 0)
            {
                clsCommon.MsgBox("Ký hiệu vé bóc sai, bạn hãy sửa lại", 0);
                txtkyhieu.Focus();
            }
            else
            {
                if ((Int32) clsCommon.Parse(txtgiave.Text, 0) == 5000)
                    {
                        if (!dmcanbo_dal.Kiemtrakyhieuboc(BienTc.KyHieuVe))
                            {
                                rptinveboc5 rpt = new rptinveboc5();             
                                rpt.ShowRibbonPreviewDialog();
                            }
                        else
                            {
                                clsCommon.MsgBox("Ký hiệu vé bóc này chưa quay!", 0);
                                txtkyhieu.Focus();
                            }
                    }
                    else
                    {
                        if (!dmcanbo_dal.Kiemtrakyhieuboc2(BienTc.KyHieuVe))
                        {
                            rptinveboc2 rpt = new rptinveboc2();             
                            rpt.ShowRibbonPreviewDialog();
                        }
                        else
                        {
                            clsCommon.MsgBox("Ký hiệu vé bóc này chưa quay!", 0);
                            txtkyhieu.Focus();
                        }
                    }
            }
        }
        private DMVETT_DAL dmcanbo_dal = new DMVETT_DAL();

        private void frmInbocph5_Load(object sender, EventArgs e)
        {
            txtgiave.Text = "5000";
        }

        private void txtkyhieu_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "Down" || e.KeyCode == Keys.Enter)
            {
                btnin.Focus();
            }
        }

        private void btndong_Click(object sender, EventArgs e)
        {
            this.Close();
        }  
        }
    }
